USE [Test_Events]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[spGetCompanyProfiles]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[spGetCompanyProfiles]
GO


CREATE PROCEDURE [dbo].[spGetCompanyProfiles]
AS
BEGIN
	DECLARE @transaction_isolation_level SMALLINT;
	
	SELECT @transaction_isolation_level = transaction_isolation_level
    FROM sys.dm_exec_requests
    WHERE session_id = @@spid;
	
	print('spGetCompanyProfiles transaction_isolation_level: ' + STR(@transaction_isolation_level))

	--SELECT CompanyProfiles.CompanyId, Companies.Name AS CompanyName, Companies.CIQID AS CapitalIQID, CompanyProfiles.LastUpdated
	--FROM dbo.EventIndicatorCompanyProfiles AS CompanyProfiles 
	--INNER JOIN [DATA-SRV-01].DSRSystem.dbo.Companies AS Companies ON CompanyProfiles.CompanyId = Companies.CompanyId
	--WHERE (Companies.IsParked = 0) AND (Companies.WorkingVersion > 1002) AND (Companies.IsControversyResearchOnly = 0)
	--AND CompanyProfiles.Status = 0
	
	--UNION

	--SELECT CompanyProfiles.CompanyId, Companies.Name AS CompanyName, Companies.CIQID AS CapitalIQID, CompanyProfiles.LastUpdated
	--FROM dbo.EventIndicatorCompanyProfiles AS CompanyProfiles 
	--INNER JOIN [DATA-SRV-01].DSRSystem.dbo.Companies AS Companies ON CompanyProfiles.CompanyId = Companies.CompanyId
	--WHERE (Companies.IsControversyResearchOnly = 1)
	--AND CompanyProfiles.Status = 0

	SELECT CompanyProfiles.CompanyId, Companies.Name AS CompanyName, Companies.CIQID AS CapitalIQID, CompanyProfiles.LastUpdated
	FROM dbo.EventIndicatorCompanyProfiles AS CompanyProfiles 
	INNER JOIN [DATA-SRV-01].DSRSystem.dbo.Companies AS Companies ON CompanyProfiles.CompanyId = Companies.CompanyId
	WHERE CompanyProfiles.Status = 0

END
GO


